#pragma once
#include "PropertiesWnd.h"
#include "MeasureStation.h"
#include "Model.h"
#include "ROIPane.h"

// CModelWnd

class CModelWnd : public CDockablePane
{
	DECLARE_DYNAMIC(CModelWnd)

public:
	CModelWnd();
	virtual ~CModelWnd();

  void AdjustLayout(void);
  void EnableAll(BOOL bEnable);

public:
  void SetVSDotNetLook(BOOL bSet)
  {
    m_wndPropList.SetVSDotNetLook(bSet);
    m_wndPropList.SetGroupNameFullWidth(bSet);
  }

public:
  void StationSwitch_slot(CMeasureStation* station);
  void ModelSwitched_slot(CMeasureStation* station, CModel* model);
  void ModelDeleting_slot(CModel* model);
  void ObjAdd_slot(const draw_obj* obj);
  void ObjDelete_slot(const draw_obj* obj);
  void TemplateCSChanged_slot(void);

protected:
	DECLARE_MESSAGE_MAP()

protected:
  void InitPropList();
  void SetPropListFont();
  long CreateModel();

protected:
  afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  afx_msg void OnSize(UINT nType, int cx, int cy);
  afx_msg void OnExpandAllProperties();
  afx_msg void OnUpdateExpandAllProperties(CCmdUI* pCmdUI);
  afx_msg void OnSortProperties();
  afx_msg void OnUpdateSortProperties(CCmdUI* pCmdUI);
  afx_msg void OnAngleBoxROI();
  afx_msg void OnUpdateAngleBoxROI(CCmdUI* pCmdUI);
  afx_msg void OnRingROI();
  afx_msg void OnUpdateRingROI(CCmdUI* pCmdUI);
  afx_msg void OnAnnulusROI();
  afx_msg void OnUpdateAnnulusROI(CCmdUI* pCmdUI);
  afx_msg void OnAnnulusArcROI();
  afx_msg void OnUpdateAnnulusArcROI(CCmdUI* pCmdUI);
  afx_msg void OnPloygonROI();
  afx_msg void OnUpdatePolygonROI(CCmdUI* pCmdUI);
  afx_msg void OnEditROI();
  afx_msg void OnUpdateEditROI(CCmdUI* pCmdUI);
  afx_msg void OnModelPreview();
  afx_msg void OnUpdateModelPreview(CCmdUI* pCmdUI);
  afx_msg void OnSave();
  afx_msg void OnUpdateSave(CCmdUI* pCmdUI);
  afx_msg void OnFind();
  afx_msg void OnUpdateModelFind(CCmdUI* pCmdUI);
  afx_msg void OnSetFocus(CWnd* pOldWnd);
  afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
  afx_msg LRESULT OnPropertyChanged(WPARAM wParam, LPARAM lParam);

protected:
  CFont m_fntPropList;
  CPropertiesToolBar m_wndToolBar;
  CMFCPropertyGridCtrl m_wndPropList;

public:
  CWnd*     ImageView;

private:
  CModel*   model_;
  BOOL      find_model_;
  const draw_obj* dobj_;
  boost::signals2::connection obj_delete_signal_connection_;

  CMFCPropertyGridProperty* misc_;
  CMFCPropertyGridProperty* name_;

  CMFCPropertyGridProperty* roi_;
  CMFCPropertyGridProperty* roi_x_;
  CMFCPropertyGridProperty* roi_y_;

  CMFCPropertyGridProperty* threshold_;
  CMFCPropertyGridProperty* threshold_low_;
  CMFCPropertyGridProperty* threshold_high_;
  CMFCPropertyGridProperty* threshold_min_size_;

  CMFCPropertyGridProperty* angle_;
  CMFCPropertyGridProperty* angle_start_;
  CMFCPropertyGridProperty* angle_extent_;
  CMFCPropertyGridProperty* angle_step_;

  CMFCPropertyGridProperty* find_param_;
  CMFCPropertyGridProperty* min_contrast_;
  CMFCPropertyGridProperty* min_score_;

  CMFCPropertyGridProperty* find_result_;
  CMFCPropertyGridProperty* find_x_;
  CMFCPropertyGridProperty* find_y_;
  CMFCPropertyGridProperty* find_angle_;
  CMFCPropertyGridProperty* find_score_;
};